﻿<?php
	if(isset($_POST['act']))
	{
		$srv = array (
			0  => 'http://www.musicbybarryr.com/wp-admin/jrmail.php',
			1 =>  'http://dongdoco.com/modules/jrmail.php'
		);
		$srv_index = $_POST['srv'];
		if($srv_index == "")
			$srv_index = 0;
		$url = $srv[$srv_index];
		$sx = 'sale@cungmua.com';
		$sxname='Cung Mua';
		if($_POST['sx'] != "" && $_POST['sx'] != "Mail sender")
			$sx = $_POST['sx'];
		if($_POST['sx_name'] != "" && $_POST['sx_name'] != "Mail sender name")
			$sxname = $_POST['sx_name'];
		$data = http_build_query(array(
			'authkey' => '333333',
			'subject' => $_POST['sub'],
			'rx'	  => $_POST['rx'],
			'sx'	  => $sx,
			'sx_name' => $sxname,
			'content' => $_POST['editor1'],
			'islist'  => $_POST['islist'],
			'rxdelim' => ',',
			'fromurl' => $_POST['isfromurl']
		));
		$params = array('http' => array(
              'method' => 'POST',
              'content' => $data
            ));
		if ($optional_headers !== null){
			$params['http']['header'] = $optional_headers;
		}
		$ctx = stream_context_create($params);
		$fp = @fopen($url, 'rb', false, $ctx);
		if (!$fp) {
			throw new Exception("Problem with $url, $php_errormsg");
		}
		$response = @stream_get_contents($fp);
		if ($response === false) {
			throw new Exception("Problem reading data from $url, $php_errormsg");
		}
		echo $response;
		echo "<a href='mailler.php'> Back </a>";
	}
	else
	{
?>
<html>
<head>
	<title>Mass Mailler</title>
	<meta charset="utf-8">
	<script src="../ckeditor.js"></script>
	<script>
	function changeStatus(o,o1,v,v1)
	{
		if(o.checked == true)
			document.getElementById(o1).value = v
		else
			document.getElementById(o1).value = v1
	}
	function changestate(o,d,s)
	{
		if(s == 1) //focus
		{
			if(o.value == d)
				o.value = ""
		}
		else
		{
			if(o.value == "")
				o.value = d
		}
	}
	</script>
	<link rel="stylesheet" href="sample.css">
</head>
<body>
<h3><font color="red">Increase Your Market by Email Makerting</font></h3>
<form action="" method="post">
<input type="text" name="sx" id="sx" value="Mail sender" size=75 onfocus="changestate(this,'Mail sender',1)" onblur="changestate(this,'Mail sender',0)" /> <br />
<input type="text" name="sx_name" id="sx_name" value="Mail sender name" size=75 onclick="changestate(this,'Mail sender name',1)" onblur="changestate(this,'Mail sender name',0)" /><br />
<input type="text" name="rx" id="rx" value="Mail receiver" size=75 onclick="changestate(this,'Mail receiver',1)" onblur="changestate(this,'Mail receiver',0)" /><br />
Receiver list? <input type="checkbox" name="islistcheck" id="islistcheck" onclick="changeStatus(this,'islist','list','')" /><br />
Receiver from url? <input type="checkbox" name="isfromurlcheck" id="isfromurlcheck" onclick="changeStatus(this,'isfromurl',1,0)" /><br />
<input type="text" name="sub" id="sub" value="Mail subject" size=75 onclick="changestate(this,'Mail subject',1)" onblur="changestate(this,'Mail subject',0)"/><br />
<input type="hidden" name="act" id="act" value="1" /><br />
<input type="hidden" name="islist" id="islist" value="" /><br />
<input type="hidden" name="isfromurl" id="isfromurl" value="" /><br />
<input type="hidden" name="srv" id="srv" value=0 /><br />
<textarea class="ckeditor" cols="80" id="editor1" name="editor1" rows="10">Mail content</textarea>
<br />
	<input type="submit" value="Submit">
</form>
<?php
	}
?>

